using System.Collections.Generic;
using System.IO;
using System;
using UnityEditor;
using UnityEngine;

[InitializeOnLoad]
public class BuildHotFixEditor
{
    /// <summary>
	/// 程序集路径
	/// </summary>
    const string AssembliesPath = "Hotfix_Project/bin/Debug";
    /// <summary>
	/// 发布目标路径
	/// </summary>
    const string BuildPath = "Assets/GameRes/HotFixDll";
    /// <summary>
	/// hotfixdll
	/// </summary>
    const string HotfixDll = "Hotfix_Project.dll";
    /// <summary>
	/// horfixpdb
	/// </summary>
    const string HotfixPdb = "Hotfix_Project.pdb";

    static BuildHotFixEditor(){
        string fixDll = Path.Combine(BuildPath, "Unity.Hotfix.dll.bytes");
        string fixPdb = Path.Combine(BuildPath, "Unity.Hotfix.pdb.bytes");

        //File.Copy(Path.Combine(AssembliesPath, HotfixDll),fixDll,true);
        //File.Copy(Path.Combine(AssembliesPath, HotfixPdb),fixPdb,true);

        File.WriteAllBytes(fixDll, File.ReadAllBytes(Path.Combine(AssembliesPath, HotfixDll)));
        File.WriteAllBytes(fixPdb, File.ReadAllBytes(Path.Combine(AssembliesPath, HotfixPdb)));

        AssetDatabase.Refresh();

        Debug.Log("程序集拷贝完成");
    }
}
